Skip to content

Fix optimized grouping of locals#8577

Merged
tlively merged 1 commit intomainfrom
local-grouping-bug
Apr 7, 2026
Merged

Fix optimized grouping of locals#8577
tlively merged 1 commit intomainfrom
local-grouping-bug

Conversation

@tlively
Copy link
Copy Markdown
Member

@tlively tlively commented Apr 7, 2026

In #8568 we optimized the grouping of locals in the binary writer to account for how types will be written given the enabled features. However, that change did not properly update the handling of scratch locals accordingly, leading to inconsistencies in the indices assigned to local types in different locations. Fix the problem by reverting the changes from #8568 and handling the mapping from IR types to written types at a lower level; specifically, create a new TypeIndexMap type that extends InsertOrderedMap but always applies asWrittenGivenFeatures to its keys. Use this new map type both for the numLocalsByType map and the scratchLocals map.

In #8568 we optimized the grouping of locals in the binary writer to account for how types will be written given the enabled features. However, that change did not properly update the handling of scratch locals accordingly, leading to inconsistencies in the indices assigned to local types in different locations. Fix the problem by reverting the changes from #8568 and handling the mapping from IR types to written types at a lower level; specifically, create a new `TypeIndexMap` type that extends `InsertOrderedMap` but always applies `asWrittenGivenFeatures` to its keys. Use this new map type both for the `numLocalsByType` map and the `scratchLocals` map.
@tlively tlively requested a review from kripken April 7, 2026 17:02
@tlively tlively requested a review from a team as a code owner April 7, 2026 17:02
@tlively tlively merged commit a6f85e5 into main Apr 7, 2026
16 checks passed
@tlively tlively deleted the local-grouping-bug branch April 7, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants